package com.coolxiaoyao.web.inner;

import com.coolxiaoyao.common.inner.DefaultResponseBody;

/**
 * @author Kerry on 18/09/25
 */

public class DefaultResponseFactory {

    public static DefaultResponseBody create(Throwable throwable, io.netty.handler.codec.http.HttpResponseStatus status) {
        return new DefaultResponseBody.Builder()
                .status(status.code())
                .msg(throwable.getMessage())
                .data(status.reasonPhrase()).build();
    }


    public static DefaultResponseBody error5XX(Throwable throwable) {
        return new DefaultResponseBody.Builder().msg(throwable.getMessage()).build();
    }

}
